package files;

import lombok.extern.java.Log;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * Created with Intel IDEA.
 *
 * @Auther: gjt
 * @Date: 2024/10/25 21:19
 */

@Log
public class ReadFiles {
    private static String path = "D:\\新建文件夹\\";

    private static ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10);
    public static void main(String[] args) {
        File file = new File(path);
        File[] files = null;
        if (file.isDirectory() || file.exists()) {
            files = file.listFiles();
        } else {
            log.warning("不是文件夹或者不存在");
            return;
        }

        if (null == files) return;
        for (File item : files) {
            ReadUpdateTask readUpdateTask = new ReadUpdateTask(item, "线程-" + item.getName());
            executor.submit(readUpdateTask);
        }
    }

}
